<html>
	<head>
		<title>CCC PseudoCode - Loading...</title>
			<script language="javascript" type="text/javascript">
	<!--
	// Example provided by Martin Honnen
	// A function that sets cookie values properly
	// The cookieName and cookieValue arguments are mandatory
	// but all other arguments are optional.
	// The expires argument is a Date object.
	// The path defines the part of the document tree on the server
	// that the cookie is valid for.
	// The domain argument allows multiple server hosts to be used.
	// The secure value is boolean and only applicable for use
	// with HTTPS: connections.
	function setCookie(cookieName, cookieValue, expires, path, domain, secure) {
		updateDone = false;
		domain = "www.sydwell.com";
		path = "R:";
		//alert("cookieName = #" + cookieName + "# cookieValue = #" + cookieValue + "# domain = #" + domain + "#");
		document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; EXPIRES=' + expires.toGMTString() : '')
		+ (path ? '; PATH=' + path : '')
		+ (domain ? '; DOMAIN=' + domain : '')
		+ (secure ? '; SECURE' : '');
	}
	
	/* A complementary function to unwrap a cookie. */
	function getCookie(cookieName) {
		var cookieValue = null;
		var posName = document.cookie.indexOf(escape(cookieName) + '=');
		if (posName != -1)	{
			var posValue = posName + (escape(cookieName) + '=').length;
			var endPos = document.cookie.indexOf(';', posValue);
			if (endPos != -1) {
				cookieValue = unescape(document.cookie.substring(posValue, endPos));
			}	else {
				cookieValue = unescape(document.cookie.substring(posValue));
			}
		}
		return cookieValue;
	}
	/* Gets all the cookies */
	function getAllCookies() {
		updateDone = false;
		var allcook = unescape(document.cookie);
		var stillc = true;
		var vend = 0;
		var valend = 0;
		var j = 0
		do {
			vend = allcook.indexOf("=");
			if (vend == -1) break;
			valend = allcook.indexOf(";")
			if (valend == -1) {
				valend = allcook.length;
				stillc = false;
			}
			vars[j] = allcook.substring(0, vend );
			values[j] = allcook.substring(vend + 1, valend);
		//	alert(" a cookie found with name #" + vars[j] + "# and value #" + values[j] + "#");
			allcook = allcook.substr(valend + 2);
			//alert(" left is #" + allcook + "#"); 
			j++;
		} while (stillc); 
	}
	
	/* Call by the java applet to show the help file  */
	function showHelp() {
		updateDone = false;
		window.open('CCC_Help.html', 'helpwin', 'left=20, top=20, width=500, height=500, resizable=1, scrollbars= 1');
	}
	
	/* Call by the java applet to show the help file  */
	function showHelpIndex(ref) {
		window.open('oofs.pdf#nameddest=' + ref , 'textbook', 
		'left=20, top=20, width=500, height=500, resizable=1, scrollbars= 1');
	}

	/* Call by the java applet to execute the HTML file  */
	function runJavaCode(ref) {
		window.open( ref );
	}
	
	/* Call   */
	function resize(env) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
			width=document.body.clientWidth;
			height=document.body.clientHeight;
		} else {
			var netscapeScrollWidth=1;
			width=window.innerWidth - netscapeScrollWidth;
			height=window.innerHeight - netscapeScrollWidth; 
		}
  		document.CCC.width = width;
		document.CCC.height = height;
		//window.scroll(0,0);
		//document.CCC.setTitle("JUNNKK");
	} //end function resize

	function closeJAM() {
	//	document.JAM.close();
	}
	
	/* Will be called by Java code in applet */
	/* Note make calling line as simple as possible  */
	function setAppletTitle(newName) {
		updateDone = false;
		/* The alert line might prevent title change*/
		//alert("attempt to set title " + newName);
		/* Do not set the title of these elements */
		// document.JAM.setTitle(newName);	
		// document.CCC.setTitle(newName);	
		document.title = newName;
	}
	
	function setCookieGeneral(cookieName, cookieValue) {
		updateDone = false;
		//alert(" cookieGeneral() #" + cookieName + "# value #" + cookieValue + "#");
		setCookie(cookieName, cookieValue, t101); 
	}

 	/**
	 Not called from CCC but window.onbeforeunload = unloadingBrowser;
	 to stop the user from moving away from the page when code is not saved
	*/
	function unloadingBrowser(env) {
		env = window.event;
		var possible = false;
		if (env == undefined) {
			//alert("env is undefined ");
		} else {
			//alert (env.clientY + " " + env.type);
			//alert ("X=" + env.clientX + " Y=" + env.clientY + " " + env.which);
			/*syd_improve might one to implement more accurate check */
			if ((env.clientY < -5)) {
				possible = true;
			}
		}
		//evt.srcElement
		//alert(" hi " + evt.pageY);
		var someway = getCookie("codeDirty");
		if (someway == "true" && possible) {
			message = "The changes to your code was NOT saved! \nAll data will be lost."
		} else {
			//alert (" not cause " + env.clientY + "#" + someway + "#");
			message = undefined;
		}
    	return message;
	}
	
	function codeDirty(state)
	{
		needsSaving = state;
	}
	/**
	* Start of browser code
	*/
	//Required to enable warnings when leaving a page
	window.onbeforeunload = unloadingBrowser;
	var vars = Array();
	var values = Array();
	var now = new Date();
	var t101 = new Date(now.getTime() + 1000 * 60 * 60 * 2400);
-->
			</script>
		</head>
		<body 
			onresize="resize()"
			onload="resize(); closeJAM();" 
			style="margin: 0"
		>	
		<!--onbeforeunload = "un(event)";-->
			<applet 
				name="CCC"
				code="pseudo_ASH.PseudoMain.class" 
				width="800" 
				height="600" 
				archive="CCCs.jar"
			>
			</applet>
			<hr />
			<script language="javascript" type="text/javascript">
			
			<!--
   /**
	* Vital Writting a dynamic applet with parameter 
	*/
	document.writeln("<APPLET code=\"service.CookieCutter\" name=\"JAM\" archive=\"CookieCutter.jar\"	width=\"0\" height=\"0\" >");
	//document.writeln("<PARAM name=\"fname\" value=\"" + getCookie("FONTNAME") + "\">");
	//document.writeln("<PARAM name=\"fsize\" value=\"" + getCookie("FONTSIZE") + "\">");
	//document.writeln("<PARAM name=\"fname\" value=\"" + getCookie("TABSIZE") + "\">");
	getAllCookies();
	for (k = 0; k < vars.length; k++) {  
		document.writeln("<PARAM name=\"" + vars[k]  + "\" value=\"" + values[k] + "\">");
		//alert(" writeing " + "<PARAM name=\"" + vars[k]  + "\" value=\"" + values[k] + "\">");
	}
	document.writeln("<\/APPLET>");
	// Added since 1.4b14 to 
	/*	Unfortunately, in Navigator 2.0, documents that contain images and do not contain frames may invoke the onLoad()
	handler early, from JavaSScript Definitive guide pg200 */
	window.loaded = true;
		-->
		
		
		</script>  
	</body>
</html>
